package com.vf.admin.miaodong.controller;

import com.vf.admin.common.BaseController;
import com.vf.admin.common.entity.Result;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.entity.AppNew;
import com.vf.admin.miaodong.service.AfterNewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 会话管理
 */
@Controller
@RequestMapping("/after/huihua")
public class AfterHuihuaController extends BaseController {

    @Autowired
    AfterNewService afterNewService;

    /**
     * 获取所有会话
     */
    @RequestMapping("/list")
    public String getAllUser(SplitPageBean splitPage, String nick, String phone, String startDate, String endDate) {
        Map<String, Object> map = new HashMap<>();
        map.put("nick", nick);
        map.put("phone", phone);
        map.put("startDate", startDate);
        map.put("endDate", endDate);
        List<AppNew> maps = afterNewService.findList(map, splitPage);
        request.setAttribute("nick",nick);
        request.setAttribute("startDate",startDate);
        request.setAttribute("endDate",endDate);
        request.setAttribute("phone",phone);
        request.setAttribute("list",maps);
        request.setAttribute("splitPage",splitPage);
        return this.sucess("/web/after/huihua/list");
    }

    /**
     * 删除会话
     */
    @RequestMapping("/delHuihua")
    @ResponseBody
    public Result delHuihua(Integer id) {
        try {
            afterNewService.del(id);
            return this.sucessJSON("删除成功");
        }catch (Exception e) {
            return this.errorJSON("系统繁忙");
        }
    }


}
